﻿using MD5Hash;
using MediatR;
using MS.Data.API.Write.Applicant.Command;
using MS.Data.Domain;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel
{
    /// <summary>
    /// 更新命令处理
    /// </summary>
    public class UpdateCommandHandel : IRequestHandler<UpdateCommand, APIResult<List<Permission>>>
    {
        IBaseRepository<Permission> perRep;

        public UpdateCommandHandel(IBaseRepository<Permission> perRep)
        {
            this.perRep = perRep;
        }

        public Task<APIResult<List<Permission>>> Handle(UpdateCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Permission>> result = new APIResult<List<Permission>>();
            result.code = APIEnum.更新成功;
            result.mes = APIEnum.更新成功.ToString();

            var list = perRep.GetAll().Where(s=>s.PermissionId==request.PermissionId);

            result.data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
